/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import ru.jSkyRoom.interfaces.major.Enchantment;
import ru.jSkyRoom.interfaces.major.Keyword;
import ru.jSkyRoom.interfaces.major.Weapon;
import ru.jSkyRoom.interfaces.stub.CritEffect;
import ru.jSkyRoom.interfaces.stub.EquipSlot;
import ru.jSkyRoom.interfaces.stub.FirstPersonModel;
import ru.jSkyRoom.interfaces.stub.ImpactSet;
import ru.jSkyRoom.interfaces.stub.JSkyScriptPackage;
import ru.jSkyRoom.interfaces.stub.JSkySound;
import ru.jSkyRoom.interfaces.sub.JSkyModel;
import skyproc.FormID;
import skyproc.Model;
import skyproc.ScriptPackage;
import skyproc.WEAP;

/**
 *
 * @author Rakev
 */
public class WeaponBridge extends DescriptionedMajorBridge<WEAP> implements Weapon {

    public WeaponBridge(WEAP adapting) {
        super(adapting);
    }

    @Override
    public Set<Keyword> getKeywords() {
        Collection<FormID> keyWordFormIds = getRawObject().getKeywordSet().getKeywordRefs();
        Collection<Keyword> keyWords = getFinderFactory().createKeywordFinder().find(keyWordFormIds);

        return Collections.unmodifiableSet(new HashSet<>(keyWords));
    }

    @Override
    public void addKeyword(Keyword keyword) {
        getRawObject().getKeywordSet().addKeywordRef(keyword.getForm());
    }

    @Override
    public void removeKeyword(Keyword keyword) {
        getRawObject().getKeywordSet().removeKeywordRef(keyword.getForm());
    }

    @Override
    public int getValue() {
        return getRawObject().getValue();
    }

    @Override
    public void setValue(int value) {
        getRawObject().setValue(value);
    }

    @Override
    public float getWeight() {
        return getRawObject().getWeight();
    }

    @Override
    public void setWeight(float weight) {
        getRawObject().setWeight((float) weight);
    }

    @Override
    public JSkyScriptPackage getScriptPackage() {
        ScriptPackage scriptPackage = getRawObject().getScriptPackage();
        return getBridgeFactory().createBridge(scriptPackage);
    }

    @Override
    public int getDamage() {
        return getRawObject().getDamage();
    }

    @Override
    public void setDamage(int damage) {
        getRawObject().setDamage(damage);
    }

    @Override
    public int getEnchantmentCharge() {
        return getRawObject().getEnchantmentCharge();
    }

    @Override
    public void setEnchantmentCharge(int amount) {
        getRawObject().setEnchantmentCharge(amount);
    }

    @Override
    public Enchantment getEnchantment() {
        FormID enchFormId = getRawObject().getEnchantment();
        return getFinderFactory().createEnchantmentFinder().find(enchFormId);
    }

    @Override
    public void setEnchantment(Enchantment enchantment) {
        FormID id = getIdProducer().produce(enchantment);
        getRawObject().setEnchantment(id);
    }

    @Override
    public EquipSlot getEquipSlot() {
        FormID id = getRawObject().getEquipmentSlot();
        return getFinderFactory().createEquipSlotFinder().find(id);
    }

    @Override
    public void setEquipSlot(EquipSlot slot) {
        FormID id = getIdProducer().produce(slot);
        getRawObject().setEquipmentSlot(id);
    }

    @Override
    public ImpactSet getImpactData() {
        FormID id = getRawObject().getImpactSet();
        return getFinderFactory().createImpactSetFinder().find(id);
    }

    @Override
    public void setImpactData(ImpactSet impactSet) {
        FormID id = getIdProducer().produce(impactSet);
        getRawObject().setImpactSet(id);
    }

    @Override
    public JSkyModel getModel() {
        Model model = getRawObject().getModelData();
        return getBridgeFactory().createBridge(model);
    }

    @Override
    public JSkySound getUnequipSound() {
        FormID soundId = getRawObject().getSheathSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setUnequipSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setSheathSound(id);
    }

    @Override
    public JSkySound getEquipSound() {
        FormID soundId = getRawObject().getDrawSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setEquipSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setDrawSound(id);
    }

    @Override
    public JSkySound getFailSound() {
        FormID soundId = getRawObject().getSwingSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setFailSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setSwingSound(id);
    }

    @Override
    public JSkySound getIdleSound() {
        FormID soundId = getRawObject().getBoundWeaponSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setIdleSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setBoundWeaponSound(id);
    }

    @Override
    public WEAP.WeaponType getWeaponType() {
        return getRawObject().getWeaponType();
    }

    @Override
    public void setWeaponType(WEAP.WeaponType type) {
        getRawObject().setWeaponType(type);
    }

    @Override
    public float getSpeed() {
        return getRawObject().getSpeed();
    }

    @Override
    public void setSpeed(float speed) {
        getRawObject().setSpeed((float) speed);
    }

    @Override
    public float getReach() {
        return getRawObject().getReach();
    }

    @Override
    public void setReach(float reach) {
        getRawObject().setReach((float) reach);
    }

    @Override
    public float getSightFOV() {
        return getRawObject().getSightFOV();
    }

    @Override
    public void setSightFOV(float fov) {
        getRawObject().setSightFOV((float) fov);
    }

    @Override
    public int getVATS() {
        return getRawObject().getVATS();
    }

    @Override
    public void setVATS(int vats) {
        getRawObject().setVATS(vats);
    }

    @Override
    public int getProjectiles() {
        return getRawObject().getNumProjectiles();
    }

    @Override
    public void setProjectiles(int gprojectiles) {
        getRawObject().setNumProjectiles(gprojectiles);
    }

    @Override
    public float getMinRange() {
        return getRawObject().getMinRange();
    }

    @Override
    public void setMinRange(float minRange) {
        getRawObject().setMinRange((float) minRange);
    }

    @Override
    public float getMaxRange() {
        return getRawObject().getMaxRange();
    }

    @Override
    public void setMaxRange(float maxRange) {
        getRawObject().setMaxRange((float) maxRange);
    }

    @Override
    public float getStagger() {
        return getRawObject().getStagger();
    }

    @Override
    public void setStagger(float stagger) {
        getRawObject().setStagger((float) stagger);
    }

    @Override
    public int getCritDamage() {
        return getRawObject().getCritDamage();
    }

    @Override
    public void setCritDamage(int critDmg) {
        getRawObject().setCritDamage(critDmg);
    }

    @Override
    public float getCritMult() {
        return getRawObject().getCritMult();
    }

    @Override
    public void setCritMult(float critMult) {
        getRawObject().setCritMult((float) critMult);
    }

    @Override
    public boolean getCritEffectOnDeath() {
        return getRawObject().getCritEffectOnDeath();
    }

    @Override
    public void setCritEffectOnDeath() {
        getRawObject().setCritEffectOnDeath(true);
    }

    @Override
    public void unsetCritEffectOnDeath() {
        getRawObject().setCritEffectOnDeath(false);
    }

    @Override
    public CritEffect getCritEffect() {
        FormID id = getRawObject().getCritEffect();
        return getFinderFactory().createCritEffectFinder().find(id);
    }

    @Override
    public void setCritEffect(CritEffect critEffect) {
        FormID id = getIdProducer().produce(critEffect);
        getRawObject().setCritEffect(id);
    }

    @Override
    public boolean getFlag(WEAP.WeaponFlag flag) {
        return getRawObject().get(flag);
    }

    @Override
    public void setFlag(WEAP.WeaponFlag flag) {
        getRawObject().set(flag, true);
    }

    @Override
    public void unsetFlag(WEAP.WeaponFlag flag) {
        getRawObject().set(flag, false);
    }

    @Override
    public Weapon getTemplate() {
        FormID templateFormId = getRawObject().getTemplate();
        return getFinderFactory().createWeaponFinder().find(templateFormId);
    }

    @Override
    public void setTemplate(Weapon template) {
        FormID id = getIdProducer().produce(template);
        getRawObject().setTemplate(id);
    }

    @Override
    public FirstPersonModel getFirstPersonModel() {
        FormID id = getRawObject().getFirstPersonModel();
        return getFinderFactory().createFirstPersonModelFinder().find(id);
    }

    @Override
    public void setFirstPersonModel(FirstPersonModel firstPersonModel) {
        FormID id = getIdProducer().produce(firstPersonModel);
        getRawObject().setFirstPersonModel(id);
    }
}
